package ws

import "time"

type SessionWriteIdleTimeout struct {
	session *Session
}

func (x *SessionWriteIdleTimeout) OnTimeout() {
	x.session.sessionHandle.OnWriteIdleTimeout(x.session)
}

func (x *SessionWriteIdleTimeout) IsTimeout() bool {
	return x.session.lastWriteAt.Add(x.session.writeIdleTimeout).Before(time.Now())
}

func NewSessionWriteIdleTimeout(session *Session) *SessionWriteIdleTimeout {
	return &SessionWriteIdleTimeout{
		session: session,
	}
}
